package club.mzywucai.blog.file_system.controller;

import club.mzywucai.blog.file_system.pojo.domain.JsonData;
import club.mzywucai.blog.file_system.util.XORUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author mzywucai
 * @Description
 * @date 2019/2/12
 */
@RestController
@PropertySource({"classpath:config/application.properties"})
public class DecodeURIController {
    @Value("${file.uri.secret}")
    String secret;

    @PostMapping("/api/uri/encode")
    public JsonData decodeURI(@RequestParam("uri") String encodeURI) {
        System.out.println(encodeURI);

        String decode = XORUtil.decode(encodeURI, secret);

        return JsonData.buildSuccess(0, decode, "ok");
    }
}
